<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>分类 - 博客</title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>

<body>

  <!-- 导航 -->
  <nav class="navbar navbar-expand-lg navbar-light bg-light">
    <a class="navbar-brand" href="#">博客网站</a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarNav">
      <ul class="navbar-nav">
        <li class="nav-item"><a class="nav-link" href="index.html">首页</a></li>
        <li class="nav-item"><a class="nav-link" href="category.html">分类</a></li>
        <li class="nav-item"><a class="nav-link" href="about.html">关于</a></li>
        <li class="nav-item"><a class="nav-link" href="contact.html">联系</a></li>
        <li class="nav-item"><a class="nav-link" href="login.html">登录</a></li>
      </ul>
    </div>
  </nav>

  <!-- 分类筛选 -->
  <div class="container mt-5">
    <div class="row">
      <div class="col-md-3">
        <ul class="list-group" id="categoryList">
          <li class="list-group-item" data-category="tech">技术</li>
          <li class="list-group-item" data-category="life">生活</li>
          <li class="list-group-item" data-category="education">教育</li>
        </ul>
      </div>
      <div class="col-md-9">
        <h2>分类下的文章</h2>
        <div class="row" id="article-list">
          <div class="col-md-4 mb-4 category-tech">
            <div class="card">
              <img src="http://cdn.qiniu.liyansheng.top/img/20241202213616.png" class="card-img-top" alt="文章封面">
              <div class="card-body">
                <h5 class="card-title">技术文章1</h5>
                <a href="#" class="btn btn-primary">阅读更多</a>
              </div>
            </div>
          </div>
          <div class="col-md-4 mb-4 category-life">
            <div class="card">
              <img src="http://cdn.qiniu.liyansheng.top/img/20241202213616.png" class="card-img-top" alt="文章封面">
              <div class="card-body">
                <h5 class="card-title">生活文章1</h5>
                <a href="#" class="btn btn-primary">阅读更多</a>
              </div>
            </div>
          </div>
          <div class="col-md-4 mb-4 category-tech">
            <div class="card">
              <img src="http://cdn.qiniu.liyansheng.top/img/20241202213616.png" class="card-img-top" alt="文章封面">
              <div class="card-body">
                <h5 class="card-title">技术文章1</h5>
                <a href="#" class="btn btn-primary">阅读更多</a>
              </div>
            </div>
          </div>
          <div class="col-md-4 mb-4 category-life">
            <div class="card">
              <img src="http://cdn.qiniu.liyansheng.top/img/20241202213616.png" class="card-img-top" alt="文章封面">
              <div class="card-body">
                <h5 class="card-title">生活文章1</h5>
                <a href="#" class="btn btn-primary">阅读更多</a>
              </div>
            </div>
          </div>
          <!-- 更多文章 -->
        </div>
      </div>
    </div>
  </div>

  <!-- 引入Bootstrap JS -->
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>

  <!-- jQuery 代码 -->
  <script>
    $(document).ready(function () {
      $("#categoryList li").click(function () {
        var category = $(this).data("category");
        $("#article-list .col-md-4").each(function () {
          if ($(this).hasClass("category-" + category)) {
            $(this).show();
          } else {
            $(this).hide();
          }
        });
      });
    });
  </script>

</body>

</html>